package com.fiberhome.ztelauncher.xml;

import com.thoughtworks.xstream.XStream;

import java.io.InputStream;

/**
 * Created by Deed on 2018/3/20.
 */

public class XmlTransfer {
//    private static final XStream X_STREAM = new XStream();
    public static  <T> T parseTo(InputStream is,Class<T> cls) {
        try {
            XStream xs = new XStream();
            xs.autodetectAnnotations(true);
            xs.processAnnotations(cls);
            xs.alias(cls.getSimpleName(), cls);
            return (T) xs.fromXML(is);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
